package jbpm;

import java.util.List;

import junit.framework.TestCase;

import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;

public class HelloTest extends TestCase {

	//----发布流程定义  
    //第一步：启动流程引擎  
    ProcessEngine engine;  
    
  //测试发布  
    public void testDeploy(){  
        //获取流程服务  
        RepositoryService service=engine.getRepositoryService();  
        //把流程定义发布到流程引擎中  
        String developementId=service.createDeployment()  
                              .addResourceFromClasspath("hello.jpdl.xml").deploy();  
        //----查看流程定义  
        //发布流程定义信息，查看已发布流程定义列表  
        List<ProcessDefinition> definitions=service.createProcessDefinitionQuery().list();//执行搜索  
        for (ProcessDefinition processDefinition : definitions) {  
            System.out.println(processDefinition.getId());  
        }  
        //----删除流程定义，这里用级联删除会比较好  
        service.deleteDeploymentCascade(developementId);  
        //查看输出后流程定义的个数  
        System.out.println(service.createProcessDefinitionQuery().list().size());  
          
    }  
    public HelloTest(){  
    	engine=Configuration.getProcessEngine();  
    }  
}
